package com.example.smart.base.dialog

import android.content.Context
import android.view.Gravity
import android.view.View
import com.example.lib.extend.dip2px
import com.example.lib.extend.gone
import com.example.lib.extend.visi
import com.example.smart.R
import com.example.smart.base.dialog.base.BaseDialog
import com.example.smart.databinding.DialogLoadingBinding

class LoadingDialog(context: Context) : BaseDialog<DialogLoadingBinding>(dialogContext = context,
    width = context.dip2px(120f),
    height = context.dip2px(120f),
    gravity = Gravity.CENTER) {
    var text = "loading"

    override fun setLayoutRes() = R.layout.dialog_loading

    override fun afterViewCreate(view: View?) {
        banCancel()
    }

    override fun show() {
        super.show()
        if (text.isEmpty()) {
            binding.LayoutLoadingText.gone()
        } else {
            binding.LayoutLoadingText.visi()
            binding.LayoutLoadingText.text = text
        }
    }
}